package studychinese.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hschinese.pronunciation.R;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import studychinese.model.TextRecultBean;


/**
 * Created by lenovo on 2017/4/9.
 */
public class GvResultPinyinAdapter extends AppAdapter {
    private int mPosstion = -1;
   private List<TextRecultBean.DataBean> data;
    public GvResultPinyinAdapter(List list, Context context) {
        super(list, context);
     this.data=list;
    }
  /*  */


    @Override
    public View createView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.fragment_gv_result_pinyin, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if(data.get(position).isBooleanFlag()){

            viewHolder.itemGvResultPinyinRight.setVisibility(View.VISIBLE);
            viewHolder.itemGvResultPinyinRight.setText(data.get(position).getRightPy());
            viewHolder.itemGvResultPinyinWrong.setVisibility(View.INVISIBLE);
        }else {
            viewHolder.itemGvResultPinyinRight.setVisibility(View.VISIBLE);
            viewHolder.itemGvResultPinyinWrong.setVisibility(View.VISIBLE);
            viewHolder.itemGvResultPinyinRight.setText(data.get(position).getRightPy());
            if(data.get(position).getWrongPy().equals("")){
                viewHolder.itemGvResultPinyinWrong.setText("没有填写");
            }else {
                viewHolder.itemGvResultPinyinWrong.setText(data.get(position).getWrongPy());
            }

        }

        return convertView;
    }


    static class ViewHolder {
        @Bind(R.id.item_gv_result_pinyin_wrong)
        TextView itemGvResultPinyinWrong;
        @Bind(R.id.item_gv_result_pinyin_right)
        TextView itemGvResultPinyinRight;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
